 /**********************
 * Matthew Tanner
 * tannerm.onid.orst.edu
 * CS362
 * Assignment #3 unittest4.c
 * Tests the gainCard function in dominion.c
 ***********************/

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include <math.h>
#include "rngs.h"
#include "tests.h"

void unittest4(){

	//set minimum required variables
	struct gameState g;
	int players = 2;
	int k[10] = {adventurer, council_room, sea_hag, gardens, mine, remodel, smithy, village, baron, great_hall};
	int seed = 100;
	int res, numPlayerCards, player, setflag, supply, discard, deck, hand;	

	//initialize game
	res = initializeGame(players, k, seed, &g);
	player = whoseTurn(&g);
	supply = supplyCount(copper, &g);
	deck = 5;
	hand = 5;

	printf("Testing gainCard:\n");
	printf("Initial supply: %d, discard: %d, deck: %d, hand: %d\n",
			supplyCount(copper, &g), g.discardCount[player], g.deckCount[player],
			numHandCards(&g));
	printf("Initial # of cards in discard pile: %d\n", g.discardCount[player]);
	printf("Initial # of cards in deck: %d\n", g.deckCount[player]);
	printf("Initial # of cards in hand: %d\n", numHandCards(&g));

	// Condition #1, flag 0 to add to discard
	printf("calling with setFlag == 0 : add to discard\n");
	setflag = 0;
	supply --;
	discard ++;
	gainCard(copper, &g, setflag, player);
	printf("Expected supply: %d, discard: %d, deck: %d, hand: %d\n", supply, 
			discard, deck, hand);
	printf("Actual supply: %d, discard: %d, deck: %d, hand: %d\n", 
		supplyCount(copper, &g), g.discardCount[player], g.deckCount[player],
		numHandCards(&g));


	// Condition #2, flag 1 to add to deck
	printf("calling with setFlag == 1 : add to deck\n");
	setflag = 1;
	supply --;
	deck ++;
	gainCard(copper, &g, setflag, player);
	printf("Expected supply: %d, discard: %d, deck: %d, hand: %d\n", supply, 
			discard, deck, hand);
	printf("Actual supply: %d, discard: %d, deck: %d, hand: %d\n", 
		supplyCount(copper, &g), g.discardCount[player], g.deckCount[player],
		numHandCards(&g));

	// Condition #1, flag 2 to add to hand 
	printf("calling with setFlag == 2 : add to hand\n");
	setflag = 2;
	supply --;
	hand ++;
	gainCard(copper, &g, setflag, player);
	printf("Expected supply: %d, discard: %d, deck: %d, hand: %d\n", supply, 
			discard, deck, hand);
	printf("Actual supply: %d, discard: %d, deck: %d, hand: %d\n", 
		supplyCount(copper, &g), g.discardCount[player], g.deckCount[player],
		numHandCards(&g));
}
